package com.company.singletonExample;

/**
 * Created by yijy on 2017/6/14.
 * Java单例——双重校验
 */
public class SingletonDoubleSafeModel {
    private volatile static SingletonDoubleSafeModel instance = null;
    private SingletonDoubleSafeModel(){}

    public static SingletonDoubleSafeModel getInstance(){
        if(instance == null){
            synchronized (SingletonDoubleSafeModel.class){
                if(instance == null){
                    instance = new SingletonDoubleSafeModel();
                }
            }
        }
        return instance;
    }
}

